package com.nyt.report.config;

import com.nyt.report.util.FileUtil;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

@Configuration
public class KafkaConfig {

    /**
     * 管理对象配置，用于kafka管理
     *
     * @return
     */
    @Bean
    public AdminClient adminClient() {
        Map config = FileUtil.loadFromFile("kafka_admin.properties");
        AdminClient client = AdminClient.create(config);
        return client;
    }


    @Bean
    public KafkaProducer kafkaProducer() {
        Map config = FileUtil.loadFromFile("kafka_producer.properties");
        KafkaProducer producer = new KafkaProducer(config);
        return producer;
    }
}
